<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>
    <div id="community">
        <div id="forum-header">
            <?php echo $community_header; ?>
            <div>
                <h1><a href="<?php echo $headline_link; ?>"><?php echo $text_headline_name ;?></a></h1>
            </div>
        </div>
        <div id="post-main">
        <form name="post-form" id="post-form" action="<?php echo $action; ?>" method="POST">
            <?php if($showDraft){ ?>
            <dl class="gray-box">
                <dd><?php echo $text_draft_commentary_title; ?></dd>
                <dd><?php echo $text_draft_commentary; ?></dd>
                <dd>
                    <?php foreach($drafts as $draft){ ?>
                    <dl class="gray-box-content">
                        <dd class="draft-subject">
                            <?php echo $text_draft_subject; ?>
                            <a href="<?php echo $draft['draft_subject_link']; ?>"><?php echo $draft['draft_subject']; ?></a>
                        </dd>
                        <dd><?php echo $text_draft_time; ?><?php echo $draft['save_time']; ?></dd>
                        <dd>
                            <?php echo $text_draft_location; ?>
                            <a href="<?php echo $draft['draft_location_link']; ?>"><?php echo $draft['location']; ?></a>
                        </dd>
                    </dl>
                <?php } ?>
                </dd>
            </dl>
            <?php } ?>
            <dl class="gray-box">
                <dd>
                    <?php echo $text_post; ?>
                    <?php if ($error_flood_limit) { ?>
                    <span class="error"><?php echo $error_flood_limit; ?></span>
                    <?php } ?>
                </dd>
                <dd id="post-subject">
                <?php if(isset($topic_category_enabled) && $topic_category_enabled){ ?>
                    <?php if(!empty($topic_cats)){ ?>
                    <select name="topic-category">
                        <option value="<?php echo $text_topic_cats; ?>"><?php echo $text_topic_cats; ?></option>
                        <?php foreach($topic_cats as $topic_cat){ ?>
                        <option value="<?php echo $topic_cat['topic_category_id']; ?>" <?php echo $topic_category_id==$topic_cat['topic_category_id'] ? 'selected=selected' : ''; ?>><?php echo $topic_cat['topic_category_title']; ?></option>
                        <?php } ?>
                     </select>
                    <?php } ?>
                <?php } ?>
                <?php echo $entry_subject ?><input type="text" name="subject" value="<?php echo $subject ?>" />
                <?php if($error_subject){ ?>
                <span class="inline_error"><?php echo $error_subject; ?></span>
                <?php } ?>
                <?php if($error_topic_cats){ ?>
                <span class="inline_error"><?php echo $error_topic_cats; ?></span>
                <?php } ?>
                </dd>
                <!--<dd class="post-rule">
                </dd>-->
            </dl>
            <dl class="gray-box">
                <?php if($bbcode_enable){ ?>
                <dt id="bb_code">
                    <?php foreach($bb_buttons as $bb_button){ ?>
                    <?php echo $bb_button; ?>
                    <?php } ?>
                    <?php if($error_content){ ?>
                    <span class="error">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $error_content; ?></span>
                    <?php } ?>
                </dt>
                <?php } ?>
                <dd id="post-textarea">
                    <textarea name="content" id="content" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();"><?php echo $content; ?></textarea>
                    <?php if(isset($topic_first_post_id)){ ?>
                    <input type="hidden" name="topic-first-post-id" value="<?php echo $topic_first_post_id; ?>" />
                    <?php } ?>
                    <?php if(isset($topic_type)){ ?>
                    <input type="hidden" name="topic-type" value="<?php echo $topic_type; ?>" />
                    <?php } ?>
                </dd>
                <?php if($smiles_enable){ ?>
                <dd id="ubb-smile" class="post-smile">
                    <span>Smilies</span>
                    <?php echo $smiles; ?>
                </dd>
                <?php } ?>
                <dd id="bbcode_enable">
                    <span><?php echo $bbcode_enable ? $text_bbcode_enabled : $text_bbcode_disabled; ?></span>
                    <span><?php echo $bbcode_enable&&isset($bbcode_img_enable)&&$bbcode_img_enable ? $text_img_enabled : $text_img_disabled; ?></span>
                    <span><?php echo $bbcode_enable&&isset($bbcode_flash_enable)&&$bbcode_flash_enable ? $text_flash_enabled : $text_flash_disabled; ?></span>
                    <span><?php echo $bbcode_enable&&isset($bbcode_url_enable)&&$bbcode_url_enable ? $text_url_enabled : $text_url_disabled; ?></span>
                    <span><?php echo $smiles_enable ? $text_smile_enabled : $text_smile_disabled; ?></span>
                </dd>
            </dl>
            <?php if(!$showDraft){ ?>
            <dl class="gray-box">
                <dd class="center-up">
                    <?php if(!$is_edit_post){ ?>
                    <?php if(isset($draft) && $draft){ ?>
                    <input class="input-buttons" type="submit" name="loaddraft" value="<?php echo $text_loaddraft; ?>" />
                    &nbsp;&nbsp;&nbsp;
                    <?php } ?>
                    <input class="input-buttons" type="submit" name="savedraft" value="<?php echo $text_savedraft; ?>" />
                    &nbsp;&nbsp;&nbsp;
                    <?php } ?>
                    <input class="input-buttons" type="submit" name="submit" value="<?php echo $text_submit; ?>" />
                </dd>
                <?php if($captcha_enabled){ ?>
                <dd id="captcha">
                    <strong><?php echo $entry_captcha; ?></strong>
                    <input type="text" name="captcha" value="<?php echo $captcha; ?>" />
                    <img src="index.php?route=community/post/captcha" alt="Captcha Code" />
                    <?php if ($error_captcha) { ?>
                    <span class="error"><?php echo $error_captcha; ?></span>
                    <?php } ?>
                </dd>
                <?php } ?>
            </dl>
            <dl id="posting-tabs">
                <a href="#posting-options"><?php echo $text_posting_options; ?></a>
                <?php if(isset($allow_poll) && $allow_poll){ ?>
                <a href="#posting-poll"><?php echo $text_poll_creation; ?></a>
                <?php } ?>
            </dl>
            <dl class="gray-box">
                <dd id="posting-options">
                    <span class="error"><?php echo $error_poll; ?></span>
                    <dl>
                        <dd><input type="checkbox" name="disable_bbcode" <?php echo isset($is_enable_bbcode) ? $is_enable_bbcode : ''; ?> /><?php echo $text_disable_bbcode; ?></dd>
                        <dd><input type="checkbox" name="disable_smilies" <?php echo isset($is_enable_smilies) ? $is_enable_smilies : ''; ?> /><?php echo $text_disable_smilies; ?></dd>
                        <dd><input type="checkbox" name="not_parse_urls" <?php echo isset($is_enable_magic_url) ? $is_enable_magic_url : ''; ?> /><?php echo $text_not_parse_urls; ?></dd>
                        <dd><input type="checkbox" name="attach_signature" <?php echo isset($is_enable_sig) ? $is_enable_sig : 'checked="checked"'; ?> /><?php echo $text_attach_signature; ?></dd>
                        <dd><input type="checkbox" name="notify_me" <?php echo isset($is_reply_notify) ? $is_reply_notify : ''; ?> /><?php echo $text_notify_me; ?></dd>
                        <?php if($allow_feature_topic){ ?>
                        <dd><input type="checkbox" name="feature_topic" value="1" <?php echo isset($is_feature_topic) ? $is_feature_topic : ''; ?> />&#42;&#42;&nbsp;<?php echo $text_allow_feature_topic; ?></dd>
                        <?php } ?>
                        <?php if($allow_lock_topic){ ?>
                        <dd><input type="checkbox" name="lock_topic" value="1" <?php echo isset($is_lock_topic) ? $is_lock_topic : ''; ?> />&#42;&#42;&nbsp;<?php echo $text_allow_lock_topic; ?></dd>
                        <?php } ?>
                        <?php if($allow_lock_edit){ ?>
                        <dd><input type="checkbox" name="lock_edit" value="1" <?php echo isset($is_lock_edit) ? $is_lock_edit : ''; ?> />&#42;&#42;&nbsp;<?php echo $text_allow_lock_edit; ?></dd>
                        <?php } ?>
                        <?php if($allow_topic_announcement || $allow_topic_global_announcement || $allow_topic_sticky){ ?>
                        <dd>
                            <strong><?php echo $text_set_topic_as; ?></strong>&nbsp;&nbsp;
                            <input type="radio" name="set_topic_as" value="0" <?php echo $is_set_topic_as_normal; ?> /><?php echo $text_topic_normal; ?>&nbsp;
                            <?php if($allow_topic_sticky){ ?>
                            <input type="radio" name="set_topic_as" value="1" <?php echo $is_set_topic_as_sticky; ?> /><?php echo $text_topic_sticky; ?>&nbsp;
                            <?php } ?>
                            <?php if($allow_topic_announcement){ ?>
                            <input type="radio" name="set_topic_as" value="2" <?php echo $is_set_topic_as_announce; ?> /><?php echo $text_topic_announcement; ?>&nbsp;
                            <?php } ?>
                            <?php if($allow_topic_global_announcement){ ?>
                            <input type="radio" name="set_topic_as" value="3" <?php echo $is_set_topic_as_global_announce; ?> /><?php echo $text_topic_global_announcement; ?>
                            <?php } ?>
                        </dd>
                        <dd>
                            <strong><?php echo $text_stick_topic_for; ?></strong>&nbsp;&nbsp;
                            <input type="text" name="stick_topic_for" size="4" value="<?php echo $stick_days; ?>" />&nbsp;<?php echo $text_days; ?>&nbsp;&nbsp;&nbsp;&nbsp;
                            <em><?php echo $text_stick_tip; ?></em>
                        </dd>
                        <?php } ?>
                        <?php if(isset($show_post_edit_reason)){ ?>
                        <dd>
                            <strong><?php echo $text_post_edit_reason; ?></strong>&nbsp;&nbsp;
                            <input type="text" name="post_edit_reason" size="80" value="<?php echo $post_edit_reason; ?>" />
                        </dd>
                        <?php } ?>
                    </dl>
                </dd>
                <dd id="posting-poll">
                <?php if(isset($allow_poll) && $allow_poll){ ?>
                <dl class="gray-box">
                    <dd>
                        <?php echo $text_poll_tip; ?>
                    </dd>
                    <dd>
                        <span><?php echo $text_poll_question; ?></span>
                        <input id="poll-question" type="text" name="poll-question" value="<?php echo $poll_question; ?>" />
                    </dd>
                    <dd>
                        <span><?php echo $text_poll_option; ?></span>
                        <textarea name="poll-option" id="poll-option"><?php echo $poll_option; ?></textarea>
                    </dd>
                    <dd>
                        <span><?php echo $text_poll_option_per_user; ?></span>
                        <input type="text" name="poll-option-per-user" value="<?php echo $poll_option_per_user; ?>" />
                        <?php echo $text_poll_option_per_user_tip; ?>
                    </dd>
                    <dd>
                        <span><?php echo $text_poll_run_day; ?></span>
                        <input type="text" name="poll-run-day" value="<?php echo $poll_run_day; ?>" />
                        <?php echo $text_poll_run_day_tip; ?>
                    </dd>
                </dl>
                <?php } ?>
                </dd>
            </dl>
            <?php } ?>
        </form>
        </div>      
    </div>
<script type="text/javascript"><!--
<?php if($bbcode_enable || $smiles_enable){ ?>
    var form_name = 'post-form';
    var text_name = 'content';
<?php if($bbcode_enable){ ?>
    var bbcode = new Array();
    var bbtags = new Array(<?php echo implode(',',$bb_tags); ?>);
<?php } ?>
--></script>
<script type="text/javascript" src="catalog/view/javascript/editor.js"></script>
<?php } ?>
<script type="text/javascript" src="catalog/view/javascript/forum_fn.js"></script>
<?php if($bbcode_enable){ ?>
<div id="font_colour_palette" class="font_colour_palette" style="display:none;">
<script type="text/javascript"><!--
    function change_palette(id){
        hideOrShow(id);
        e = document.getElementById(id);

        if (e.style.display == 'block'){
            document.getElementById('font_color').title = '<?php echo $text_font_color_close; ?>';
        }else{
            document.getElementById('font_color').title = '<?php echo $text_font_color; ?>';
        }
    }
    colorPalette('h', 15, 10);
--></script>
<script type="text/javascript"><!--
$('#posting-tabs a').tabs();

$('#community input[name=\'header-keyword\']').keydown(function(e) {
    if (e.keyCode == 13) {
        $('#header-search-button').trigger('click');
    }
});

$('#header-search-button').bind('click', function() {
    url = 'index.php?route=community/search';

    var keyword = $('#forum-header-bar-search input[name=\'header-keyword\']').attr('value');

    url += '&kw=' + encodeURIComponent(keyword) + '&sw=psm&sb=lpt&or=desc&lr=all';

    location = url;
});
//--></script>
</div>
<?php } ?>
<?php  echo $footer; ?>